package com.sara.util;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class UncaughtExceptionService extends Service {

	private static final String TAG = "UncaughtExceptionService";

	@Override
	public void onStart(Intent intent, int startId) {
		super.onStart(intent, startId);
		String stackTrace = intent.getStringExtra("stackTrace");

		Mail m = new Mail("sarabearmio2@gmail.com", "sarabearmio2123");
		String[] toArr = new String[] { "13710530762@139.com" };
		m.setTo(toArr);
		m.setFrom("sara_mio@163.com");
		m.setSubject("Triple Play Exception Report!");
		m.setBody(stackTrace);
		try {
			Log.d(TAG, "Send error email");
			Log.d(TAG, "Send error email success");
			m.send();
		} catch (Exception e) {
			Log.d(TAG, "Send error email fail");
			e.printStackTrace();
		}
		stopSelf();
	}

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

}
